<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php"); ?>



<?php
$new_detail_nid=$_GET['nid'];

//设置需要搜索的表格的前缀后缀
$table_Suffix='detail';
$table=$table_Prefix.$table_Suffix;
//设置需要搜索的表格的前缀后缀


$list = select_lines_all_items($table,""," nid=$new_detail_nid ",1);

//删除详情照片
$str = $list[0]['detail'];
$preg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';//匹配img标签的正则表达式
preg_match_all($preg, $str, $allImg);//这里匹配所有的img

foreach ($allImg[1] as $detailImage){
    $status = unlink(ROOT_PATH_.$detailImage);
//    echo ROOT_PATH_.$detailImage;
//    echo '<br/>';
}

//删除数据关联的所有照片
$imgList = ['icon','video','video_img','video_img2','video_path','video_path2',
    'image1','image2','image3','image4','image5','image6','image7','image8','image9','image10',
    'banner','extend_img'];
foreach ($imgList as $imgItem){
    if(!empty($list[0][$imgItem])){
        unlink(ROOT_PATH_.'/uploadfiles/'.$theme_folder.'/'.$list[0][$imgItem]);
//        echo ROOT_PATH_.'/uploadfiles/'.$theme_folder.'/'.$list[0][$imgItem];
//        echo '<br/>';
    }
}

//执行删除
$sql = " DELETE FROM $table WHERE nid=$new_detail_nid";
$query=mysql_query($sql) or die (mysql_error());

$table_Suffix='relation';
$table=$table_Prefix.$table_Suffix;
$sql2 = " DELETE FROM $table WHERE detail_nid=$new_detail_nid";
$query=mysql_query($sql2) or die (mysql_error());


mysql_close($con);

echo 1;//表示成功


?>


